package org.tgcloud.group;

import org.apache.tomcat.util.http.LegacyCookieProcessor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.tgcloud.group.core.GlobalStatic;

import java.util.Arrays;
import java.util.List;

@SpringBootApplication
@EnableScheduling
@EnableCaching
@EnableTransactionManagement
@ServletComponentScan // 配置原始servlet请求
@MapperScan("org.tgcloud.group.repository")
public class ShopMetalApplication {

	public static void main(String[] args) {
		SpringApplication.run(ShopMetalApplication.class, args);
		GlobalStatic.init();
		System.out.println("http://localhost:8080/checkorder/doc.html");
	}


	@Bean
	public WebServerFactoryCustomizer<TomcatServletWebServerFactory> cookieProcessorCustomizer() {
		return tomcatServletWebServerFactory -> tomcatServletWebServerFactory.addContextCustomizers((TomcatContextCustomizer) context -> {
			context.setCookieProcessor(new LegacyCookieProcessor());
		});
	}

}
